package com.hdu.clj.fitness

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.util.Log
import android.widget.Toast

class DayNumDatabase(val context: Context,name:String,version:Int,user:String): SQLiteOpenHelper(context,name,null,version){

    private val dayNumBook = "create table $user(" +
            "id integer primary key autoincrement," +
            "date text," +
            "num integer," +
            "card integer)"

    val tab = user

    override fun onCreate(db: SQLiteDatabase) {
        Log.d("curdata",dayNumBook)
        db.execSQL(dayNumBook)
    }

    override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
//        db.execSQL(dayNumBook)
        db.execSQL("drop table if exists $tab")
        onCreate(db)
    }

//    override fun onDowngrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
//        onUpgrade(db,oldVersion,newVersion)
//    }
}